<template>
  <el-container class="zhuti">
    <!-- 头部 -->
    <el-header>
      <div class="a1">
        <span>你好,{{ this.$store.state.userData.userName }}</span>
      </div>
    </el-header>
    <el-container>
      <!-- 侧边栏 -->
      <el-aside width="200px">
        <el-menu
          background-color="#333744"
          text-color="#fff"
          active-text-color="#ffd04b"
          :unique-opened="true"
          router
          
        >
          <!-- 一级菜单 :default-active="activePathadmin"-->
          <el-menu-item index="userData" @click="saveNav('/userData')" class="ce" >
            <i class="el-icon-user" ></i>
            <span slot="title">个人信息</span>
          </el-menu-item>
          <el-menu-item  index="bookList" @click="saveNav('/bookList')" class="ce">
            <i class="el-icon-collection"></i>
            <span slot="title">收藏夹</span>
          </el-menu-item>
          <el-menu-item index="userHistory" @click="saveNav('/userHistory')" class="ce">
            <i class="el-icon-document"></i>
            <span slot="title">浏览历史</span>
          </el-menu-item>
          <el-menu-item index="comment" @click="saveNav('/comment')" class="ce">
            <i class="el-icon-edit"></i>
            <span slot="title">我的评论</span>
          </el-menu-item>
        </el-menu>
      </el-aside>

      <!-- 主体 -->
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  // 生命周期函数，调用getMenuList
  created() {
    this.activePathUser = window.sessionStorage.getItem("activePathUser");
    //this.$router.push(`/bookList`)
  },
  data() {
    return {
      adminname: "",
      //被激活的地址保存
      activePathUser: ""
    };
  },

  methods: {
    //保存侧边栏状态
    saveNav(activePathUser) {
      window.sessionStorage.setItem("activePathUser", activePathUser);
      this.activePathUser = activePathUser;
    },
  }
};
</script>

<style lang="less" scoped>
* {
  margin: 0px;
  padding: 0px;
}

.zhuti {
  height: 100%;
  width: 100%;
}

.el-header {
  position: relative;
  background-color: rgb(132, 154, 175);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-left: 0px;
  color: rgb(22, 24, 24);
  font-size: 20px;

  .a1 {
    width: 20%;
    height: 100%;
    display: flex;
    align-items: center;
    margin-left: 30px;
    span {
      margin-left: 10px;
    }
  }

  /* .a2{
        position: absolute;
        top:15%;
        right: 3%;
    } */
}

.el-aside {
  background-color: #333744;

  .el-menu {
    border-right: 0px;
  }
}

.el-main {
  background-color: rgba(210, 225, 238, 0.6);
}
.ce{
    font-size:18px;
}
</style>
